var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const ROOT_PATH = path.resolve(__dirname)
var config = {
  devtool: false,
  entry: {
    'server': ['./app/server_entry.jsx']
  },
  output: {
    path: __dirname + '/dist/',
    filename: 'server/server.js',
    // chunkFilename:'server/[name].[chunkhash:5].chunk.js',
    libraryTarget: 'commonjs2'
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  externals: Object.keys(require('./package.json').dependencies),
  module: {
    loaders: [
      {
        test: /\.js?$/,
        exclude: /(node_modules)/,
        loader: 'babel-loader'
      },
      {
        test: /\.jsx?$/,
        exclude: '/(node_modules)/',
        loader: 'babel-loader'
      },
      {test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=20&name=resource/[name].[ext]'},

      {
        test: /\.css$/, loader: 'css-loader'
      },
      {
        test: /\.scss$/, loader: 'css-loader!sass-loader'
      }
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.API_BASE': '"http://localhost:3334"',
      'process.env.RENDER_METHOD': '"server"'
    })
  ]
}

module.exports = config
